package com.jielin.handling.service.record.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jielin.handling.entity.record.RecordDetailed;
import com.jielin.handling.entity.record.RecordStop;
import com.jielin.handling.entity.tsuspect.TSuspec;
import com.jielin.handling.mapper.record.RecordDetailedMapper;
import com.jielin.handling.mapper.record.RecordStopMapper;
import com.jielin.handling.mapper.tsuspect.TSuspecMapper;
import com.jielin.handling.service.record.RecordStopService;
import com.jielin.handling.util.StringUtil;

@Service
public class RecordStopServiceimpl implements RecordStopService {
	@Autowired
	private RecordStopMapper recordStopMapper;
	@Autowired
	private RecordDetailedMapper recordDetailedMapper;
	@Autowired
	TSuspecMapper tSuspecMapper;

	@Override
	public int addStop(RecordStop reStop) {
		return recordStopMapper.addStop(reStop);
	}

	@Override
	public int updateStop(String reStopid) {
		return recordStopMapper.updateStop(reStopid);
	}

	@Override
	public List<RecordStop> findAllStopByRecordDetailedId(String recorddetailedid) {
		List<RecordStop> list = recordStopMapper.findAllStopByRecordDetailedId(recorddetailedid);
		for (RecordStop recordStop : list) {
			if (recordStop != null) {
				if (!StringUtil.isEmpty(recordStop.getSuspectId())) {
					TSuspec ts = tSuspecMapper.selectByPrimaryKey(recordStop.getSuspectId());
					recordStop.setGoType(ts.getGotoType());
				}
			}
		}
		return list;
	}
}
